package org.depsea.oss.config;

import org.depsea.oss.config.tenant.DefaultTenantOssConfigurationFactory;
import org.depsea.oss.config.tenant.TenantOssConfigProvider;
import org.depsea.oss.config.tenant.TenantOssConfigurationFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

@ConditionalOnBean(TenantOssConfigProvider.class)
@AutoConfiguration
@AutoConfigureAfter(OssAutoConfiguration.class)
public class TenantOssAutoConfiguration {

    @ConditionalOnMissingBean(TenantOssConfigurationFactory.class)
    @Bean
    public TenantOssConfigurationFactory tenantOssConfigurationFactory(TenantOssConfigProvider configProvider) {
        return new DefaultTenantOssConfigurationFactory(configProvider);
    }
}
